<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>  
<html>  
<head>  
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>Hello, World</title>  
<style type="text/css">  
html{height:100%}  
body{height:100%;margin:0px;padding:0px}  
#container{
	height:100%;
	width:100%;
}  
</style>  
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=UZ6dGTXWk6bfXYd5NGUxPnnmBnY2OVsg">
//v2.0版本的引用方式：src="http://api.map.baidu.com/api?v=2.0&ak=您的密钥"
//v1.4版本及以前版本的引用方式：src="http://api.map.baidu.com/api?v=1.4&key=您的密钥&callback=initialize"
</script>
</head>  

<body>  
<div id="container"></div> 
<script type="text/javascript"> 
	var map = new BMap.Map("container");      
	map.addControl(new BMap.NavigationControl());    
	map.addControl(new BMap.ScaleControl());    
	map.addControl(new BMap.OverviewMapControl());    
	map.addControl(new BMap.MapTypeControl());  
	var arr= ["杭州广播电视大学","杭州市西湖区文一西路70号","杭州市德胜东村","金色蓝庭"];
	//map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);      
	// 创建地址解析器实例     
	var myGeo = new BMap.Geocoder();    
	myGeo.getPoint("杭州广播电视大学",function (point){
		alert(point.lng);
		alert(point.lat);
	})
	// 将地址解析结果显示在地图上，并调整地图视野    
	//for(var i = 0;i<arr.length;i++){
		//alert(arr[i]);
		//myGeo.getPoint(arr[i], function(point){      
	      //    if (point) {      
	        //      map.centerAndZoom(point, 16);      
	          //    map.addOverlay(new BMap.Marker(point));      
	         // }      
	      //}, "杭州市");
	//}
	for(var i = 0;i<arr.length;i++){
		alert(arr[i]);
		var info = arr[i];
		myGeo.getPoint(info, function(point){      
	          if (point) {      
	              map.centerAndZoom(point, 16);  
	              var marker = new BMap.Marker(point); 
	              map.addOverlay(marker);
	              marker.addEventListener("click",function(e){
	            	  alert(e.point.lng+","+e.point.lat)
	            	  var opts = {    
	            			  width : 250,     // 信息窗口宽度    
	            			  height: 100,     // 信息窗口高度    
	            			  title : "Hello"  // 信息窗口标题   
	            			 }    
	            			 var infoWindow = new BMap.InfoWindow("gs;fkdl", opts);  // 创建信息窗口对象    
	            			 map.openInfoWindow(infoWindow, e.point);      // 打开信息窗口
	              })
	          }      
	      }, "杭州市");
	}
	
	
	
	
</script>  
</body>  
</html>